const mongoose = require('mongoose')
const { preSave } = require('../utils')

const bookSchema = new mongoose.Schema({
    name: String, //书名
    price: Number, //价格
    author: String, //作者
    press: String,
    ISBN: String,
    quantity: Number,
    publicationDate: Number, //出版日期
    type: String, // 类别
    meta: {
        createAt: {
            type: Number,
            default: (new Date()).getTime(),
        },
        updateAt: {
            type: Number,
            default: (new Date()).getTime(),
        },
    },
})

bookSchema.pre('save', preSave)
module.exports = bookSchema
